package com.authsphere.security.account.api.bind;

import com.authsphere.common.entity.PluginData;
import com.authsphere.common.enums.PluginAfterEnum;
import com.authsphere.plugin.api.AuthSphereAfterPluginChain;
import com.authsphere.plugin.api.WebExchange;
import com.authsphere.plugin.base.AbstractAuthSphereAfterPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @program: AuthSphere
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/25 16:34
 **/
public class AccountBindAfterPlugin extends AbstractAuthSphereAfterPlugin {

    private static final Logger log = LoggerFactory.getLogger(AccountBindAfterPlugin.class);
    private final AccountBindService accountBindService;

    public AccountBindAfterPlugin(AccountBindService accountBindService) {
        this.accountBindService = accountBindService;
    }

    @Override
    protected void doExecute(WebExchange exchange, AuthSphereAfterPluginChain chain, PluginData pluginData) {
        accountBindService.bind(exchange);
        chain.execute(exchange);
    }

    @Override
    public int getOrder() {
        return PluginAfterEnum.ACCOUNT_BIND.getCode();
    }
}
